I think you should use the await keyword
try{
var user = await model.findOne({ _id: req.params.id});
} catch (e) {
// Handle Errors
};
Or
model.findOne({ _id: req.params.id}).then(result => {
var user = result;
}).catch(e=> {
// Handle Errors
});
Have you added mergeParams in your router?
This options adds params object to the request
const router = express.Router({ mergeParams: true });
then
/predict/:id results in req.params.id
By default this option is disabled in express
The problem is you are not using await so in the line console.log(user.examenes) the variable user is not the data returned by mongo; is another object without attribute examenes. And trying to access the value is undefined.
So you can use:
let user = await (usuario.findOne({_id: req.params.id}))